var
	redcharset
	list/moblist = list()	/* list of all mobs for faster
								   text window updates */

world
	view = "15x11"

	New()
		..()	// do the normal stuff for world.New()

		// make a special red character set by adding red to basic set
		redcharset = 'charset.dmi' + rgb(255,0,0)

area
	icon = 'ground.dmi'

turf/wall
	icon = 'brickwall.dmi'
	opacity = 1

mob
	icon = 'yellow.dmi'
	suffix = "This is the mob's suffix"
	var
		list/Images = list()
		sd_TextWindow/Window

	Click()
		if(!usr.Window)
			usr.window()
		usr.Window.Append(src)


	Login()
		..()
		window()

	Logout()
		..()
		del src

	New()
		..()
		moblist += src

	Del()
		moblist -= src
		..()

	verb
		screensize()
			desc = "Display and adjust the size of the player's map screen"

			/* use sd_ScreenWidth() and sd_ScreenHeight() to show the
			   current size */
			src << "Current size: [client.sd_ScreenWidth()] by [client.sd_ScreenHeight()]"

			/* input new size. Sorry, sd_Input doesn't support keyboard
			   input... yet. */
			var/newsize = input("Please input a view size.")

			/* convert newsize to a num for traditional view settings
			   if no "x" found in the string */
			if(!findtext(newsize,"x")) newsize = text2num(newsize)
			client.view = newsize

			/* changing client.view messes up client.eye, so reset it
			   to point to the player's mob */
			client.eye = src

		clear()
			desc = "Clear all the images generated by the display command."
			for(var/I in Images)
				del(I)

		display(T as text,high = 1 as num)
			desc = "Display text on the map until it is cleared."
			Images += sd_Text(view(), T, locate(x,y+1,z),, high,,'ledcharset.dmi')

		say(T as text)
			desc = "Communicate with the other players with word balloons!"
			// show it as text
			world << "<b>[src]:</b> [T]"

			// delete old wordballoons to avoid overlap
			if(sd_BalloonTails && sd_BalloonTails.len)
				for(var/Tail in sd_BalloonTails)
					del(Tail)

			// show it in a ballon that will be cleared in 15 seconds
			sd_ImprovedWordBalloon(T, src)

			// show the text in everyone's text window
			for(var/mob/M in moblist)
				if(M.Window)
					M.Window.Append("[src]: [T]")

		fixed(T as text)
			desc = "Communicate with the other players with fixed width word balloons!"
			// show it as text
			world << "<b>[src]:</b> [T]"

			// delete old wordballoons to avoid overlap
			if(sd_BalloonTails && sd_BalloonTails.len)
				for(var/Tail in sd_BalloonTails)
					del(Tail)

			// show it in a ballon that will be cleared in 15 seconds
			sd_WordBalloon(view(world.view,src),T, src,fixedwidth = 3, maxheight=3)

			// show the text in everyone's text window
			for(var/mob/M in moblist)
				if(M.Window)
					M.Window.Append("[src]: [T]")

		frame(T as text)
			desc = "Like say, but with a fancier frame, red text, and leave it 30 seconds"
			world << "<b>[src]:</b><font color=red><i>[T]</i></font>"

			// delete old wordballoons to avoid overlap
			if(sd_BalloonTails && sd_BalloonTails.len)
				for(var/Tail in sd_BalloonTails)
					del(Tail)

			sd_WordBalloon(view(world.view,src), T, src,,300,redcharset,'frame.dmi',1)

			// show the text in everyone's text window
			for(var/mob/M in moblist)
				if(M.Window)
					M.Window.Append("[src]: [T]",redcharset)

		simplemenu()
			desc = "Input a text line from a menu."

			// create a short demo list
			var/list/menu = list()
			for(var/x in 1 to 4)
				menu += "Item #[x]"

			// get input
			var/list/input = sd_Input(src, menu, 7, 7, 2, 2)
			src << "You selected: [input]"

		itemmenu()
			desc = "Input one item from a menu."

			// create a list of demo items
			var/list/menu = list()
			menu += new/obj/cloak()
			menu += new/obj/sword()
			menu += new/obj/potion()

			// get input
			var/input = sd_Input(src, menu, 9, 5, 4, 3,,0)
			src << "You selected: [input]"

		multimenu()
			desc = "Input 4 items from a long list."

			// create a long demo list
			var/list/menu = list()
			for(var/x in 1 to 50)
				menu += "Item #[x]"

			// show a little window with instructions
			var/sd_TextWindow/Instructions = new(src,3,9,3,1,,0)

			Instructions.Unframe("b")	// remove the "b"ottom of the frame
			Instructions.Append("Select",redcharset,0)
			Instructions.Append("four items:",redcharset)

			// get input
			var/list/input = sd_Input(src, menu, 3, 4, 3, 5, 4,"t")
			src << "You selected:"
			for(var/i in input)
				src << "\t[i]"

			// delete the instructions window
			del Instructions

		overlay(T as text,high = 1 as num)
			desc = "Display text on the map as an overlay."
			sd_OverlayText(T, locate(x,y+1,z),, high)

		window()
			desc = "Toggle the text window at the bottom of the screen."
			if(Window)
				del Window
			else
				Window = new(usr,,-2)

obj
	// just demo items for the menu
	cloak
		icon = 'cloak.dmi'
		suffix = "Price: 100z"
	potion
		icon = 'potion.dmi'
		suffix = "Price: 800z"
	sword
		icon = 'sword.dmi'
		suffix = "Price: 300z"
